﻿using System;
using log4net;
using log4net.Repository.Hierarchy;

namespace Maxleaf.EDI.Infrastructure.Logging
{
    public class LogFactory
    {
        private static readonly Lazy<ILogger> logger = new Lazy<ILogger>(
            () =>
                {
                    log4net.Config.XmlConfigurator.Configure();

                    ILog log = LogManager.GetLogger(loggerName);
                    
                    return new Log4NetLogger(log);
                });

        private static string loggerName;

        public static ILogger GetLog4NetLogger()
        {
            return GetLog4NetLogger("Undefined");
        }

        public static ILogger GetLog4NetLogger(string loggerName)
        {
            LogFactory.loggerName = loggerName;
            return logger.Value;
        }

        ////public static ILogger GetConsoleLogger()
        ////{
        ////    return new ConsoleLogger();
        ////}
    }
}
